<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "base_sys_preview".
 *
 * @property integer $id
 * @property integer $item_id
 * @property integer $fid
 * @property integer $mid
 * @property integer $img_small_id
 * @property integer $img_thumb_id
 * @property integer $img_url_id
 */
class ItemPreviewDemo extends \yii\db\ActiveRecord
{
	public $file;
	
	public $small_img_id;
	public $thumb_img_id;
	public $big_img_id;
	public $b_t_s_img_id;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'base_sys_preview';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['item_id', 'img_small_id', 'img_thumb_id', 'img_url_id','small_img_id','thumb_img_id','big_img_id','b_t_s_img_id'], 'integer'],
            [['item_id'], 'required'],
            [['fid', 'mid', 'item_id'], 'unique', 'targetAttribute' => ['fid', 'mid', 'item_id'], 'message' => Yii::t('app','The combination of Item ID, Fid and Mid has already been taken.')]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'item_id' => Yii::t('app','Item ID'),
            'fid' => Yii::t('app','Fid'),
            'mid' => Yii::t('app','Mid'),
            'img_small_id' => 'Img Small ID',
            'img_thumb_id' => 'Img Thumb ID',
            'img_url_id' => 'Img Url ID',
            'file' => Yii::t('app','Image File'),
        ];
    }
    //与sys_image图相联系
    public function getUrlImage()
    {
    	return $this->hasOne(Image::className(),['id'=>'img_url_id']);
    }
    public function getThumbImage()
    {
    	return $this->hasOne(Image::className(),['id'=>'img_thumb_id']);
    }
    public function getSmallImage()
    {
    	return $this->hasOne(Image::className(),['id'=>'img_small_id']);
    }
    
    public function getFabric()
    {
    	return $this->hasOne(Fabric::className(),['id'=>'fid']);
    }
    public function getMaterial()
    {
    	return $this->hasOne(Material::className(),['id'=>'mid']);
    }
}
